
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>动态添加组织 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="chap5.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    编译部署
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="chap1.html">
            
                <a href="chap1.html">
            
                    
                    编译与测试网络部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="chap2.html">
            
                <a href="chap2.html">
            
                    
                    网络生成配置说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="chap3.html">
            
                <a href="chap3.html">
            
                    
                    启动网络脚本配置剖析
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    通道实践
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="chap4.html">
            
                <a href="chap4.html">
            
                    
                    创建加入通道
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="chap5.html">
            
                <a href="chap5.html">
            
                    
                    更新通道配置
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.3" data-path="chap6.html">
            
                <a href="chap6.html">
            
                    
                    动态添加组织
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    合约实践
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="chap7.html">
            
                <a href="chap7.html">
            
                    
                    安装发布智能合约
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="chap8.html">
            
                <a href="chap8.html">
            
                    
                    升级智能合约
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="chap9.html">
            
                <a href="chap9.html">
            
                    
                    智能合约设置背书策略
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="chap10.html">
            
                <a href="chap10.html">
            
                    
                    调试go智能合约
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="chap11.html">
            
                <a href="chap11.html">
            
                    
                    外部构建启动合约
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    SDK实践
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="chap12.html">
            
                <a href="chap12.html">
            
                    
                    基于Java SDK实现合约交易
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >动态添加组织</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <p>Fabric2.0&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x7EC4;&#x7EC7;&#x662F;&#x5F88;&#x591A;&#x670B;&#x53CB;&#x6BD4;&#x8F83;&#x5173;&#x6CE8;&#xFF0C;&#x6211;&#x4EEC;&#x4ECE;&#x4E0A;&#x4E00;&#x7AE0;&#x66F4;&#x65B0;&#x901A;&#x9053;&#x914D;&#x7F6E;&#x7684;&#x601D;&#x8DEF;&#x6765;&#x770B;&#xFF0C;&#x52A8;&#x6001;&#x6DFB;&#x52A0;&#x7EC4;&#x7EC7;&#x5B9E;&#x8DF5;&#x4E0A;&#x4E5F;&#x662F;&#x901A;&#x8FC7;&#x4FEE;&#x6539;&#x533A;&#x5757;&#x914D;&#x7F6E;&#x6765;&#x5B9E;&#x73B0;&#xFF0C;
&#x63A5;&#x4E0B;&#x6765;&#x7684;&#x64CD;&#x4F5C;&#x57FA;&#x4E8E;first-network&#x5DF2;&#x90E8;&#x7F72;&#x597D;&#x7684;&#x7F51;&#x7EDC;&#x3002;</p>
<h2 id="1-&#x65B0;&#x589E;org3&#x8BC1;&#x4E66;&#x914D;&#x7F6E;">1. &#x65B0;&#x589E;org3&#x8BC1;&#x4E66;&#x914D;&#x7F6E;</h2>
<p>&#x5BF9;&#x4E8E;fabric&#x7F51;&#x7EDC;&#x6765;&#x8BF4;&#xFF0C;&#x8981;&#x65B0;&#x589E;&#x4E00;&#x4E2A;&#x7EC4;&#x7EC7;&#xFF0C;&#x9996;&#x5148;&#x662F;&#x4ECE;&#x8BC1;&#x4E66;&#x5F00;&#x59CB;&#xFF0C;&#x56E0;&#x4E3A;&#x8BC1;&#x4E66;&#x5C31;&#x662F;fabric&#x91CC;&#x9762;&#x7684;&#x8EAB;&#x4EFD;&#x3002;
&#x7F16;&#x8F91;&#x8BC1;&#x4E66;&#x914D;&#x7F6E;org3-crypto.yaml &#xFF08;first-network/org3-artifacts&#xFF09;</p>
<pre><code class="lang-bash">PeerOrgs:
  <span class="hljs-comment"># ---------------------------------------------------------------------------</span>
  <span class="hljs-comment"># Org3</span>
  <span class="hljs-comment"># ---------------------------------------------------------------------------</span>
  - Name: Org3
    Domain: org3.example.com
    EnableNodeOUs: <span class="hljs-literal">true</span>
    Template:
      Count: 2
    Users:
      Count: 1
</code></pre>
<p>&#x914D;&#x7F6E;&#x4E86;Org3&#x7EC4;&#x7EC7;2&#x4E2A;&#x8282;&#x70B9;1&#x4E2A;&#x666E;&#x901A;&#x7528;&#x6237;User</p>
<p>&#x6267;&#x884C;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#xFF0C;&#x751F;&#x6210;&#x8BC1;&#x4E66;</p>
<pre><code class="lang-bash"> <span class="hljs-built_in">cd</span> org3-artifacts/
 ../../bin/cryptogen generate --config=org3-crypto.yaml --output=<span class="hljs-string">&quot;../crypto-config&quot;</span>
</code></pre>
<p>&#x6267;&#x884C;&#x5B8C;&#x6210;&#x540E;&#x67E5;&#x770B;../crypto-config/peerOrganizations&#x76EE;&#x5F55;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x65B0;&#x589E;&#x7684;&#x7EC4;&#x7EC7;&#x8BC1;&#x4E66;&#x76EE;&#x5F55;
<img src="https://img-blog.csdnimg.cn/20200226155532523.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<h2 id="2-&#x65B0;&#x589E;org3&#x5B9A;&#x4E49;&#x5230;&#x533A;&#x5757;&#x94FE;">2. &#x65B0;&#x589E;org3&#x5B9A;&#x4E49;&#x5230;&#x533A;&#x5757;&#x94FE;</h2>
<p>&#x4E4B;&#x524D;&#x6211;&#x4EEC;&#x542F;&#x52A8;&#x7684;&#x7F51;&#x7EDC;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5728;&#x542F;&#x52A8;&#x524D;&#x9700;&#x8981;&#x662F;&#x521B;&#x5EFA;&#x521B;&#x59CB;&#x533A;&#x5757;&#x4E0E;&#x901A;&#x9053;&#x914D;&#x7F6E;&#xFF0C;&#x56E0;&#x6B64;&#x5728;&#x4E3A;&#x4E86;&#x8BA9;&#x533A;&#x5757;&#x94FE;&#x77E5;&#x9053;&#x8FD9;&#x4E2A;&#x65B0;&#x6765;&#x7684;&#x7EC4;&#x7EC7;&#xFF0C;&#x9700;&#x8981;&#x628A;&#x7EC4;&#x7EC7;&#x7684;&#x914D;&#x7F6E;&#x6DFB;&#x52A0;&#x5230;&#x533A;&#x5757;&#x914D;&#x7F6E;&#x4E2D;
&#x914D;&#x7F6E;&#x6587;&#x4EF6;~\first-network\org3-artifacts\configtx.yaml
&#x6CE8;&#x610F;&#x8BC1;&#x4E66;&#x76EE;&#x5F55;&#x5FC5;&#x987B;&#x5BF9;&#x5E94;&#x6B63;&#x786E;&#x7684;org3&#x8BC1;&#x4E66;&#x76EE;&#x5F55;</p>
<p><img src="https://img-blog.csdnimg.cn/20200226155542424.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI4NTQwNDQz,size_16,color_FFFFFF,t_70" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;">
&#x5728;first-network&#x76EE;&#x5F55;&#x63A7;&#x5236;&#x53F0;&#x8F93;&#x5165;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#x751F;&#x6210;org3&#x5B9A;&#x4E49;</p>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> FABRIC_CFG_PATH=<span class="hljs-variable">$PWD</span>
 bin/configtxgen  -printOrg Org3MSP -configPath org3-artifacts &gt; channel-artifacts/org3.json
</code></pre>
<p><img src="https://img-blog.csdnimg.cn/20200226155553392.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<h2 id="3&#x542F;&#x52A8;org3&#x76F8;&#x5173;&#x8282;&#x70B9;&#x5BB9;&#x5668;">3.&#x542F;&#x52A8;org3&#x76F8;&#x5173;&#x8282;&#x70B9;&#x5BB9;&#x5668;</h2>
<p>&#x5BB9;&#x5668;&#x914D;&#x7F6E; ~/first-network/docker-compose-org3.yaml</p>
<p>&#x6267;&#x884C;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#x542F;&#x52A8; </p>
<pre><code class="lang-bash">docker-compose <span class="hljs-_">-f</span> docker-compose-org3.yaml up <span class="hljs-_">-d</span>
</code></pre>
<p><code>docker ps -a |grep org3</code> &#x67E5;&#x770B;&#x72B6;&#x6001;&#xFF0C;&#x542F;&#x52A8;&#x5931;&#x8D25;&#x4E86;&#xFF0C;&#x67E5;&#x770B;&#x65E5;&#x5FD7;&#x5982;&#x4E0B;
<img src="https://img-blog.csdnimg.cn/20200226155625467.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<p><code>Cannot run peer because error when setting up MSP of type bccsp from directory /etc/hyperledger/fabric/msp: could not load a valid signer certificate from directory /etc/hyperledger/fabric/msp/signcerts: stat /etc/hyperledger/fabric/msp/signcerts: no such file or directory</code></p>
<p>&#x4ECE;&#x9519;&#x8BEF;&#x6765;&#x770B;&#x5C31;&#x662F;&#x627E;&#x4E0D;&#x5230;&#x8BC1;&#x4E66;&#xFF0C;&#x8FD9;&#x65F6;&#x5019;&#x770B;&#x770B;docker-compose-org3.yaml&#xFF0C;&#x76EE;&#x5F55;&#x5728;org-artifacts&#x4E0B;&#xFF0C;&#x6211;&#x4EEC;&#x4E4B;&#x524D;&#x662F;&#x653E;&#x5728;first-network/crypto-config&#x4E0B;&#x7684;&#xFF0C;&#x4E3A;&#x4E86;&#x65B9;&#x4FBF;&#x539F;&#x672C;cli&#x5207;&#x6362;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x3002;
<img src="https://img-blog.csdnimg.cn/20200226155644130.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI4NTQwNDQz,size_16,color_FFFFFF,t_70" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<p>&#x77E5;&#x9053;&#x76EE;&#x5F55;&#x9519;&#x4E86;&#x4FEE;&#x6539;&#x4E3A;&#x6B63;&#x786E;&#x76EE;&#x5F55;&#x5373;&#x53EF;
<img src="https://img-blog.csdnimg.cn/20200226155651116.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI4NTQwNDQz,size_16,color_FFFFFF,t_70" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<p>&#x5220;&#x9664;&#x9519;&#x8BEF;&#x5BB9;&#x5668;</p>
<pre><code class="lang-bash"> docker-compose <span class="hljs-_">-f</span> docker-compose-org3.yaml rm
</code></pre>
<p>&#x91CD;&#x65B0;&#x542F;&#x52A8;</p>
<pre><code class="lang-bash"> docker-compose <span class="hljs-_">-f</span> docker-compose-org3.yaml up <span class="hljs-_">-d</span>
</code></pre>
<p>&#x518D;&#x6B21;&#x67E5;&#x770B;&#x5BB9;&#x5668;&#x72B6;&#x6001;&#x6210;&#x529F;&#x542F;&#x52A8;
<img src="https://img-blog.csdnimg.cn/20200226155705211.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<p>&#x770B;&#x5230;&#x8FD8;&#x591A;&#x542F;&#x52A8;&#x4E86;&#x4E00;&#x4E2A;Org3cli&#x5BB9;&#x5668;&#xFF0C;&#x662F;org3&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x7684;cli&#xFF0C;&#x53EF;&#x4EE5;&#x4E0D;&#x8D77;&#x7684;&#xFF0C;&#x4E0D;&#x8FC7;&#x542F;&#x52A8;&#x4E86;&#x5C31;&#x542F;&#x52A8;&#x4E86;</p>
<h2 id="4-&#x66F4;&#x65B0;&#x901A;&#x9053;&#x914D;&#x7F6E;">4. &#x66F4;&#x65B0;&#x901A;&#x9053;&#x914D;&#x7F6E;</h2>
<p>&#x63A5;&#x4E0B;&#x9700;&#x8981;&#x5C06;org3&#x6DFB;&#x52A0;&#x5230;&#x901A;&#x9053;&#x91CC;&#x9762;&#xFF0C;&#x6B65;&#x9AA4;&#x4E0E;&#x4E0A;&#x4E00;&#x7AE0;&#x5DEE;&#x4E0D;&#x591A;&#x3002;</p>
<p>Org3cli&#x662F;&#x9ED8;&#x8BA4;org3&#x914D;&#x7F6E;&#x7684;cli&#x5BB9;&#x5668;&#xFF0C;&#x4E0D;&#x7528;&#x767D;&#x4E0D;&#x7528;&#x3002;</p>
<p>&#x8FDB;&#x5165;org3cli  <code>docker exec -it Org3cli bash</code></p>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
<span class="hljs-built_in">export</span> CHANNEL_NAME=mychannel
<span class="hljs-built_in">echo</span> <span class="hljs-variable">$ORDERER_CA</span> &amp;&amp; <span class="hljs-built_in">echo</span> <span class="hljs-variable">$CHANNEL_NAME</span>
</code></pre>
<h3 id="41-&#x83B7;&#x53D6;&#x914D;&#x7F6E;">4.1 &#x83B7;&#x53D6;&#x914D;&#x7F6E;</h3>
<p>&#x5C06;&#x914D;&#x7F6E;&#x5207;&#x6362;&#x6210;org1&#xFF0C;&#x56E0;&#x4E3A;&#x5F53;&#x524D;org3&#x4E0D;&#x80FD;&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x901A;&#x9053;&#x6700;&#x65B0;&#x914D;&#x7F6E;</p>
<pre><code class="lang-bash">    <span class="hljs-built_in">export</span> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
    <span class="hljs-built_in">export</span> CORE_PEER_ADDRESS=peer0.org1.example.com:7051
    <span class="hljs-built_in">export</span> CORE_PEER_LOCALMSPID=<span class="hljs-string">&quot;Org1MSP&quot;</span>
   <span class="hljs-built_in">export</span>  CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
</code></pre>
<p>&#x8F93;&#x5165;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#x83B7;&#x53D6;&#x6700;&#x65B0;&#x5757;</p>
<pre><code class="lang-bash">peer channel fetch config config_block.pb -o orderer.example.com:7050 -c <span class="hljs-variable">$CHANNEL_NAME</span> --tls --cafile <span class="hljs-variable">$ORDERER_CA</span>
</code></pre>
<p>&#x83B7;&#x53D6;&#x5230;&#x7B2C;8&#x5757;&#x533A;&#x5757;
<img src="https://img-blog.csdnimg.cn/20200226155754291.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<h3 id="42-&#x4FEE;&#x6539;&#x914D;&#x7F6E;">4.2 &#x4FEE;&#x6539;&#x914D;&#x7F6E;</h3>
<p>&#x5C06;pb&#x6587;&#x4EF6;&#x8F6C;json</p>
<pre><code class="lang-bash">configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config &gt; config.json
</code></pre>
<p>&#x5C06;&#x4E4B;&#x524D;org3&#x7684;&#x914D;&#x7F6E;org3.json&#x6DFB;&#x52A0;&#x5230;config.json
&#x5148;&#x628A;&#x4E4B;&#x524D;&#x751F;&#x6210;&#x7684;org3.json&#x653E;&#x8FDB;&#x53BB;Org3cli&#x5BB9;&#x5668;</p>
<p> &#x6253;&#x5F00;&#x65B0;&#x7684;&#x63A7;&#x5236;&#x53F0;&#xFF0C;&#x5BBF;&#x4E3B;&#x673A;&#x8F93;&#x5165;&#xFF1A;</p>
<pre><code class="lang-bash">docker cp channel-artifacts/org3.json 6b9b3f2a22c4:/opt/gopath/src/github.com/hyperledger/fabric/peer
</code></pre>
<p><code>6b9b3f2a22c4&#xFF1A; Org3cli&#x5BB9;&#x5668;id</code></p>
<p>Org3cli&#x5BB9;&#x5668;&#xFF1A;</p>
<pre><code class="lang-bash">jq <span class="hljs-_">-s</span> <span class="hljs-string">&apos;.[0] * {&quot;channel_group&quot;:{&quot;groups&quot;:{&quot;Application&quot;:{&quot;groups&quot;: {&quot;Org3MSP&quot;:.[1]}}}}}&apos;</span> config.json org3.json &gt; modified_config.json
</code></pre>
<p><img src="https://img-blog.csdnimg.cn/20200226155831842.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<p>&#x5C06;config.json &#x8DDF;modified_config.json &#x8F6C;pb&#x7F16;&#x7801;</p>
<pre><code class="lang-bash">configtxlator proto_encode --input config.json --type common.Config --output config.pb

configtxlator proto_encode --input modified_config.json --type common.Config --output modified_config.pb
</code></pre>
<p>&#x8BA1;&#x7B97;&#x4E24;&#x4E2A;pb&#x5DEE;&#x5F02;</p>
<pre><code class="lang-bash">configtxlator compute_update --channel_id mychannel --original config.pb --updated modified_config.pb --output org3_update.pb
</code></pre>
<p>&#x5C06;&#x66F4;&#x65B0;&#x7684;pb&#x89E3;&#x6790;&#x4E3A;json</p>
<pre><code class="lang-bash">configtxlator proto_decode --input org3_update.pb --type common.ConfigUpdate | jq . &gt; org3_update.json
</code></pre>
<p>&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x6709;&#x4E00;&#x4E2A;&#x89E3;&#x7801;&#x540E;&#x7684;&#x66F4;&#x65B0;&#x6587;&#x4EF6;org3_update.json&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5C06;&#x5176;&#x5305;&#x88C5;&#x5728;&#x4FE1;&#x5C01;&#x6D88;&#x606F;&#x4E2D;&#x3002;&#x6B64;&#x6B65;&#x9AA4;&#x5C06;&#x4F7F;&#x6211;&#x4EEC;&#x8FD4;&#x56DE;&#x4E4B;&#x524D;&#x5220;&#x9664;&#x7684;header&#x5B57;&#x6BB5;&#x3002;&#x6211;&#x4EEC;&#x5C06;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x547D;&#x540D;&#x4E3A;org3_update_in_envelope.json&#xFF1A;</p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">&apos;{&quot;payload&quot;:{&quot;header&quot;:{&quot;channel_header&quot;:{&quot;channel_id&quot;:&quot;&apos;</span><span class="hljs-variable">$CHANNEL_NAME</span><span class="hljs-string">&apos;&quot;, &quot;type&quot;:2}},&quot;data&quot;:{&quot;config_update&quot;:&apos;</span>$(cat org3_update.json)<span class="hljs-string">&apos;}}}&apos;</span> | jq . &gt; org3_update_<span class="hljs-keyword">in</span>_envelope.json
</code></pre>
<p>&#x4F7F;&#x7528;&#x6211;&#x4EEC;&#x6B63;&#x786E;&#x683C;&#x5F0F;&#x7684;JSON &#x2013; org3_update_in_envelope.json&#x6211;&#x4EEC;&#x5C06;configtxlator&#x6700;&#x540E;&#x4E00;&#x6B21;&#x4F7F;&#x7528;&#x8BE5;&#x5DE5;&#x5177;&#xFF0C;&#x5E76;&#x5C06;&#x5176;&#x8F6C;&#x6362;&#x4E3A;Fabric&#x6240;&#x9700;&#x7684;&#x5B8C;&#x6574;protobuf&#x683C;&#x5F0F;&#x3002;&#x6211;&#x4EEC;&#x5C06;&#x547D;&#x540D;&#x6211;&#x4EEC;&#x7684;&#x6700;&#x7EC8;&#x66F4;&#x65B0;&#x5BF9;&#x8C61;org3_update_in_envelope.pb&#xFF1A;</p>
<pre><code class="lang-bash">configtxlator proto_encode --input org3_update_<span class="hljs-keyword">in</span>_envelope.json --type common.Envelope --output org3_update_<span class="hljs-keyword">in</span>_envelope.pb
</code></pre>
<h3 id="43-&#x7B7E;&#x540D;&#x5E76;&#x63D0;&#x4EA4;&#x66F4;&#x65B0;&#x914D;&#x7F6E;">4.3 &#x7B7E;&#x540D;&#x5E76;&#x63D0;&#x4EA4;&#x66F4;&#x65B0;&#x914D;&#x7F6E;</h3>
<p>&#x6DFB;&#x52A0;&#x7EC4;&#x7EC7;&#x9700;&#x8981;&#x76EE;&#x524D;&#x901A;&#x9053;&#x5927;&#x90E8;&#x5206;&#x7684;&#x7EC4;&#x7EC7;Admin&#x7B7E;&#x540D;&#xFF0C;&#x76EE;&#x524D;Org3cli&#x7684;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x662F;org1</p>
<p>&#x8F93;&#x5165;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;</p>
<pre><code class="lang-bash">peer channel signconfigtx <span class="hljs-_">-f</span> org3_update_<span class="hljs-keyword">in</span>_envelope.pb
</code></pre>
<p>&#x5207;&#x6362;&#x73AF;&#x5883;&#x4E3A;org2&#x6267;&#x884C;&#x66F4;&#x65B0;&#x914D;&#x7F6E;&#xFF0C;&#x56E0;&#x4E3A;update&#x4E5F;&#x4F1A;&#x4E3A;&#x5F53;&#x524D;&#x7EC4;&#x7EC7;&#x7B7E;&#x540D;&#xFF0C;&#x6240;&#x4EE5;&#x4E0D;&#x9700;&#x8981;&#x518D;org2&#x7B7E;&#x540D;</p>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
   <span class="hljs-built_in">export</span> CORE_PEER_ADDRESS=peer0.org2.example.com:9051
   <span class="hljs-built_in">export</span> CORE_PEER_LOCALMSPID=<span class="hljs-string">&quot;Org2MSP&quot;</span>
   <span class="hljs-built_in">export</span> CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2
</code></pre>
<p>&#x66F4;&#x65B0;&#x547D;&#x4EE4;&#xFF1A;</p>
<pre><code class="lang-bash">peer channel update <span class="hljs-_">-f</span> org3_update_<span class="hljs-keyword">in</span>_envelope.pb -c <span class="hljs-variable">$CHANNEL_NAME</span> -o orderer.example.com:7050 --tls --cafile <span class="hljs-variable">$ORDERER_CA</span>
</code></pre>
<p>&#x66F4;&#x65B0;&#x6210;&#x529F;
<img src="https://img-blog.csdnimg.cn/20200226155917248.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<h2 id="5-org3&#x52A0;&#x5165;&#x901A;&#x9053;">5. org3&#x52A0;&#x5165;&#x901A;&#x9053;</h2>
<p>&#x5207;&#x6362;&#x6210;org3&#x73AF;&#x5883;&#x53D8;&#x91CF;</p>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> CORE_PEER_LOCALMSPID=Org3MSP
<span class="hljs-built_in">export</span> CORE_PEER_ADDRESS=peer0.org3.example.com:11051
<span class="hljs-built_in">export</span> CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
<span class="hljs-built_in">export</span> CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp
</code></pre>
<p>&#x83B7;&#x53D6;mychannel 0&#x53F7;&#x5757;&#x521B;&#x59CB;&#x5757;</p>
<pre><code class="lang-bash">peer channel fetch 0 mychannel.block -o orderer.example.com:7050 -c <span class="hljs-variable">$CHANNEL_NAME</span> --tls --cafile <span class="hljs-variable">$ORDERER_CA</span>
</code></pre>
<p><img src="https://img-blog.csdnimg.cn/20200226155940536.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<p>&#x8BE5;&#x547D;&#x4EE4;&#x5C06;&#x521B;&#x4E16;&#x5757;&#x8FD4;&#x56DE;&#x5230;&#x540D;&#x4E3A;&#x7684;&#x6587;&#x4EF6;mychannel.block&#x3002;&#x73B0;&#x5728;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x6B64;&#x5757;&#x5C06;org3&#x7684;&#x8282;&#x70B9;&#x52A0;&#x5165;&#x901A;&#x9053;&#x3002;</p>
<p>&#x8F93;&#x5165;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#xFF1A;</p>
<pre><code class="lang-bash">peer channel join -b mychannel.block
</code></pre>
<p>&#x901A;&#x8FC7;peer channel list &#x9A8C;&#x8BC1;</p>
<p><img src="https://img-blog.csdnimg.cn/20200226155944923.png" alt="&#x5728;&#x8FD9;&#x91CC;&#x63D2;&#x5165;&#x56FE;&#x7247;&#x63CF;&#x8FF0;"></p>
<h2 id="6-&#x603B;&#x7ED3;">6. &#x603B;&#x7ED3;</h2>
<p>&#x52A8;&#x6001;&#x7EC4;&#x7EC7;&#x52A0;&#x5165;&#x5927;&#x6982;&#x5C31;&#x662F;&#x8FD9;&#x6837;&#xFF0C;&#x60F3;&#x5FC5;&#x5220;&#x9664;&#x7EC4;&#x7EC7;&#x4E5F;&#x662F;&#x76F8;&#x4F3C;&#x7684;&#xFF0C;&#x6D1E;&#x6089;fabric&#x7684;&#x914D;&#x7F6E;&#x539F;&#x7406;&#x5C31;&#x53EF;&#x4EE5;&#x5E94;&#x5BF9;&#x5927;&#x90E8;&#x5206;fabric&#x7684;&#x5E94;&#x7528;&#x9700;&#x6C42;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="chap5.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: 更新通道配置">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"动态添加组织","level":"1.3.3","depth":2,"next":{"title":"合约实践","level":"1.4","depth":1,"ref":"","articles":[{"title":"安装发布智能合约","level":"1.4.1","depth":2,"path":"content/chap7.md","ref":"content/chap7.md","articles":[]},{"title":"升级智能合约","level":"1.4.2","depth":2,"path":"content/chap8.md","ref":"content/chap8.md","articles":[]},{"title":"智能合约设置背书策略","level":"1.4.3","depth":2,"path":"content/chap9.md","ref":"content/chap9.md","articles":[]},{"title":"调试go智能合约","level":"1.4.4","depth":2,"path":"content/chap10.md","ref":"content/chap10.md","articles":[]},{"title":"外部构建启动合约","level":"1.4.5","depth":2,"path":"content/chap11.md","ref":"content/chap11.md","articles":[]}]},"previous":{"title":"更新通道配置","level":"1.3.2","depth":2,"path":"content/chap5.md","ref":"content/chap5.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"content/chap6.md","mtime":"2020-03-12T03:45:21.420Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-03-12T04:24:49.792Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

